package com.zll.shirotest.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
 * 自定义webmvc
 * @author zll
 */
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {

    /**
     * 解决跨域问题
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                //访问源
                .allowedOrigins("*")
                //允许访问的方法
                .allowedMethods("GET,POST,DELETE,PUT")
                .allowCredentials(true)
                .maxAge(3600)
                //允许那些请求头
                .allowedHeaders("*");
    }
}
